<script>
export default {
  name: "IndexView",
  data(){
    return{
      user:{}
    }
  },
  mounted() {
    //首页加载后，读取用户数据 JSON.parse 将json字符串转换为对象
    this.user = JSON.parse(localStorage.getItem('user'))
    console.log('user',this.user)
  }
}
</script>

<template>
  <el-container style="height: 100vh;">
    <!-- 顶部导航栏 -->
    <el-header>
        <!--        用户头像和称昵-->
        <div>
          <img :src="user.icon" style="border-radius: 50%;width: 50px;height: 50px">
          <span>{{ user.nickname }}</span>
          <router-link style="color:#fff;margin-left:100px" to="/updateUser">修改个人信息</router-link>
        </div>
    </el-header>

    <el-container>
      <!-- 侧边栏导航 -->
      <el-aside width="200px">
        <el-menu
            default-active="1"
            class="el-menu-vertical-demo"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b"
        >
          <el-submenu index="1">
            <template #title>
              <i class="el-icon-location"></i>
              <span>用户管理</span>
            </template>
            <el-menu-item index="1-1">
              <router-link to="/student" class="link">学生列表</router-link>
            </el-menu-item>
            <el-menu-item index="1-2">用户权限</el-menu-item>
          </el-submenu>
          <el-submenu index="2">
            <template #title>
              <i class="el-icon-menu"></i>
              <span>产品管理</span>
            </template>
            <el-menu-item index="2-1">产品列表</el-menu-item>
            <el-menu-item index="2-2">产品分类</el-menu-item>
          </el-submenu>
          <el-submenu index="3">
            <template #title>
              <i class="el-icon-document"></i>
              <span>订单管理</span>
            </template>
            <el-menu-item index="3-1">订单列表</el-menu-item>
            <el-menu-item index="3-2">订单统计</el-menu-item>
          </el-submenu>
          <el-submenu index="4">
            <template #title>
              <i class="el-icon-setting"></i>
              <span>系统设置</span>
            </template>
            <el-menu-item index="4-1">系统参数</el-menu-item>
            <el-menu-item index="4-2">日志管理</el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <!-- 内容区域 -->
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<style scoped>
.link{
  color: #fff;
  text-decoration: none;
}

.el-header {
  background-color: #545c64;
  color: #fff;
  line-height: 60px;
}

.el-aside {
  background-color: #545c64;
  color: #fff;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  padding: 20px;
}

.el-menu {
  border-right: none;
}

.el-menu-item {
  padding: 0 20px;
}

.el-submenu .el-menu-item {
  padding: 0 40px;
}
</style>